package org.pc2r.protocole.message;

import org.pc2r.protocole.EnumRequest;

public abstract class Message {

  private final EnumRequest request;

  protected Message(EnumRequest request) {
    assert request != null;
    this.request = request;
  }

  public final EnumRequest getType() {
    return request;
  }

  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((this.request == null) ? 0 : this.request.hashCode());
    return result;
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj)
      return true;
    if (obj == null)
      return false;
    if (getClass() != obj.getClass())
      return false;
    Message other = (Message) obj;
    if (this.request != other.request)
      return false;
    return true;
  }

  @Override
  abstract public String toString();
}
